<?php

/**
 * Plugin para enviar mails
 *
 */
class MailPlugin {

	
	/**
	* Envia un mail usando la libreria PHPMailer
	*/
	public static function send($from, $fromName, $to, $subject, $body, $attach = null) {
		require("libs/PHPMailer_v5.1/class.phpmailer.php");
		
		$mail = new PHPMailer();
		$mail->IsHTML(true);
		$mail->From = $from;
		$mail->FromName = $fromName;
		$mail->AddAddress($to);
		
		// TODO attach file
		if ($attach != null)
			$mail->AddAttachment($attach['filePath'], $attach['fileName']);
		
		$mail->Subject = $subject;
		$mail->Body = $body;
		
		return $mail->Send();
		
	}
	
}

